import React, { Component } from 'react'
import { connect } from 'dva'
import { Input } from 'antd'
import router from 'umi/router'
import { formatMessage } from 'umi/locale'
import PageHeaderWrapper from '@/components/PageHeaderWrapper'

@connect()
class Auth extends Component {
  handleTabChange = key => {
    const { match } = this.props
    switch (key) {
      case 'member':
        router.push(`${match.url}/member`)
        break
      case 'admin':
        router.push(`${match.url}/admin`)
        break
      default:
        break
    }
  }

  handleFormSubmit = (value) => {
    // eslint-disable-next-line
    console.log(value)
  }

  render() {
    const tabList = [{
      key: 'member',
      tab: formatMessage({ id: 'menu.system.user.member' }, {}),
    }, {
      key: 'admin',
      tab: formatMessage({ id: 'menu.system.user.admin' }, {}),
    }, ]

    const { match, children, location } = this.props

    return (
      <PageHeaderWrapper
        tabList={tabList}
        tabActiveKey={location.pathname.replace(`${match.path}/`, '')}
        onTabChange={this.handleTabChange}
      >
        {children}
      </PageHeaderWrapper>
    )
  }
}

export default Auth